home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 4
/
Meeting Pearls Vol. IV (1996)(GTI - Schatztruhe)[!].iso
/
Pearls
/
dev
/
Language
/
ace
/
Prgs
/
Misc
/
Task
/
task.b
< prev
next >
Wrap
Text File
|
1994-09-08
|
1KB
|
49 lines
{*
** An example of creating a sub-task in ACE.
** Adapted from RKM: Libraries (1991), p 467-468
*}
DEFLNG a-z
CONST stack_size = 1000&
CONST big_num = &H8000000
LIBRARY "exec.library"
'..library functions
DECLARE FUNCTION xWait(signal&) LIBRARY exec
DECLARE FUNCTION Forbid() LIBRARY exec
DECLARE FUNCTION Permit() LIBRARY exec
'..external functions (ami.lib)
DECLARE FUNCTION CreateTask&(taskname$,pri&,initPC&,stackSize&) EXTERNAL
DECLARE FUNCTION DeleteTask(task&) EXTERNAL
'..global variables
ADDRESS task
'..external variables
EXTERNAL LONGINT sharedvar
'..subprograms
SUB simpletask
while sharedvar < big_num
++sharedvar
wend
xWait(0)
END SUB
'..main
sharedvar = 0
print "Initial value of shared variable:";sharedvar
task = CreateTask("SimpleTask",0&,@simpletask,stack_size)
if task = 0& then STOP
print "A sub-task has been spawned which is currently"
print "incrementing a variable that is shared between"
print "the main task and the sub-task."
input "Press return...",x$
print "The value of the shared variable is now:";sharedvar
Forbid
DeleteTask(task)
Permit